import java.util.*;

/**
 * @author Martin
 *	This class describes an ingredient in a refrigerator, freezer, etc.
 */
public class Ingredient {

	private int id;
	public String name;
	private double ammount;
	public boolean isMeasuredInWheight;
	public double pricePerContainer;
	public double containerAmmount;
	public Date expirationDate;
	
	public Ingredient(int id){
		this.id = id;
		name = "newIngredient" + id;
		ammount = 0.0;
		isMeasuredInWheight = false;
		pricePerContainer = 0.0;
		containerAmmount = 1.0;
		expirationDate = new Date();
		System.out.println("New generic ingredient '" + name + "' created.");
	}
	
	public Ingredient(int id, String name, double ammount, boolean imiw, double ppc, double ca, Date date) {
		this.id = id;
		this.name = name;
		this.ammount = ammount;
		this.isMeasuredInWheight = imiw;
		this.pricePerContainer = ppc;
		this.containerAmmount = ca;
		this.expirationDate = date;
		System.out.println("New ingredient '" + name + "' created.");
	}
	
	public void addAmmount(double ammount) {
		this.ammount = this.ammount + ammount;
	}
	
	public void removeAmmount(double ammount) {
		try {
			if(this.ammount >= ammount)
				this.ammount = this.ammount - ammount;
			else
				throw new Exception();
		}
		catch(Exception e){
			System.err.println("Error, there is not enough of the ingredient to remove that much");
		}
	}
	
}
